import axios from './axios'

// 根据经纬度获取位置详情
export const getAddress = (latitude, longitude) => axios({
  url: `/position/${latitude},${longitude}`
})

// 获取食品分类列表
export const getCategories = () => axios({
  url: '/index_category',
  headers: {
    needToken: true
  }
})

// 根据经纬度获取商铺列表
export const getShopInformation = (latitude, longitude) => axios({
  url: '/shops',
  params: {
    latitude,
    longitude
  },
  headers: {
    needToken: true
  }
})

// 获取短信验证码
export const sendCode = ({phone}) => axios({
  url: '/sendcode',
  params: {
    phone
  }
})

// 用户名密码登陆
export const loginWithUser = ({username, pwd, captcha}) => axios({
  url: '/login_pwd',
  method: 'POST',
  data: {
    name: username,
    pwd,
    captcha
  }
})

// 手机号验证码登陆
export const loginWithPhone = ({phone, code}) => axios({
  url: '/login_sms',
  method: 'POST',
  data: {
    phone,
    code
  }
})

// 自动登陆
export const autoLogin = () => axios({
  url: '/auto_login',
  headers: {
    needToken: true
  }
})

// 测试接口
export const test = () => axios('/test')

// 获取shop数据
export const getShopInfo = () => axios({
  url: '/getShopInfo'
})